package com.laputacastle.dr.mapper;

import com.laputacastle.dr.model.DrCatalog;
import org.apache.ibatis.jdbc.SQL;

public class DrCatalogSqlProvider {

    public String insertSelective(DrCatalog record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("t_dr_catalog");
        
        if (record.getCId() != null) {
            sql.VALUES("c_id", "#{cId,jdbcType=VARCHAR}");
        }
        
        if (record.getCPid() != null) {
            sql.VALUES("c_pid", "#{cPid,jdbcType=VARCHAR}");
        }
        
        if (record.getCName() != null) {
            sql.VALUES("c_name", "#{cName,jdbcType=VARCHAR}");
        }
        
        if (record.getCImgurl() != null) {
            sql.VALUES("c_imgurl", "#{cImgurl,jdbcType=VARCHAR}");
        }
        
        if (record.getNValid() != null) {
            sql.VALUES("n_valid", "#{nValid,jdbcType=INTEGER}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(DrCatalog record) {
        SQL sql = new SQL();
        sql.UPDATE("t_dr_catalog");
        
        if (record.getCPid() != null) {
            sql.SET("c_pid = #{cPid,jdbcType=VARCHAR}");
        }
        
        if (record.getCName() != null) {
            sql.SET("c_name = #{cName,jdbcType=VARCHAR}");
        }
        
        if (record.getCImgurl() != null) {
            sql.SET("c_imgurl = #{cImgurl,jdbcType=VARCHAR}");
        }
        
        if (record.getNValid() != null) {
            sql.SET("n_valid = #{nValid,jdbcType=INTEGER}");
        }
        
        sql.WHERE("c_id = #{cId,jdbcType=VARCHAR}");
        
        return sql.toString();
    }
}